<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Returns a log scale for the specified domain. The arguments to this
<span class='line'>  3</span>  * constructor are optional, and equivalent to calling {@link #domain}.
<span class='line'>  4</span>  *
<span class='line'>  5</span>  * @class Represents a log scale. &lt;style
<span class='line'>  6</span>  * type="text/css">sub{line-height:0}&lt;/style> &lt;img src="../log.png"
<span class='line'>  7</span>  * width="190" height="175" align="right"> Most commonly, a log scale represents
<span class='line'>  8</span>  * a 1-dimensional log transformation from a numeric domain of input data
<span class='line'>  9</span>  * [&lt;i>d&lt;sub>0&lt;/sub>&lt;/i>, &lt;i>d&lt;sub>1&lt;/sub>&lt;/i>] to a numeric range of pixels
<span class='line'> 10</span>  * [&lt;i>r&lt;sub>0&lt;/sub>&lt;/i>, &lt;i>r&lt;sub>1&lt;/sub>&lt;/i>]. The equation for such a scale
<span class='line'> 11</span>  * is:
<span class='line'> 12</span>  *
<span class='line'> 13</span>  * &lt;blockquote>&lt;i>f(x) = (log(x) - log(d&lt;sub>0&lt;/sub>)) / (log(d&lt;sub>1&lt;/sub>) -
<span class='line'> 14</span>  * log(d&lt;sub>0&lt;/sub>)) * (r&lt;sub>1&lt;/sub> - r&lt;sub>0&lt;/sub>) +
<span class='line'> 15</span>  * r&lt;sub>0&lt;/sub>&lt;/i>&lt;/blockquote>
<span class='line'> 16</span>  *
<span class='line'> 17</span>  * where &lt;i>log(x)&lt;/i> represents the zero-symmetric logarthim of &lt;i>x&lt;/i> using
<span class='line'> 18</span>  * the scale's associated base (default: 10, see {@link pv.logSymmetric}). For
<span class='line'> 19</span>  * example, a log scale from the domain [1, 100] to range [0, 640]:
<span class='line'> 20</span>  *
<span class='line'> 21</span>  * &lt;blockquote>&lt;i>f(x) = (log(x) - log(1)) / (log(100) - log(1)) * (640 - 0) + 0&lt;/i>&lt;br>
<span class='line'> 22</span>  * &lt;i>f(x) = log(x) / 2 * 640&lt;/i>&lt;br>
<span class='line'> 23</span>  * &lt;i>f(x) = log(x) * 320&lt;/i>&lt;br>
<span class='line'> 24</span>  * &lt;/blockquote>
<span class='line'> 25</span>  *
<span class='line'> 26</span>  * Thus, saying
<span class='line'> 27</span>  *
<span class='line'> 28</span>  * &lt;pre>.height(function(d) Math.log(d) * 138.974)&lt;/pre>
<span class='line'> 29</span>  *
<span class='line'> 30</span>  * is equivalent to
<span class='line'> 31</span>  *
<span class='line'> 32</span>  * &lt;pre>.height(pv.Scale.log(1, 100).range(0, 640))&lt;/pre>
<span class='line'> 33</span>  *
<span class='line'> 34</span>  * As you can see, scales do not always make code smaller, but they should make
<span class='line'> 35</span>  * code more explicit and easier to maintain. In addition to readability, scales
<span class='line'> 36</span>  * offer several useful features:
<span class='line'> 37</span>  *
<span class='line'> 38</span>  * &lt;p>1. The range can be expressed in colors, rather than pixels. Changing the
<span class='line'> 39</span>  * example above to
<span class='line'> 40</span>  *
<span class='line'> 41</span>  * &lt;pre>.fillStyle(pv.Scale.log(1, 100).range("red", "green"))&lt;/pre>
<span class='line'> 42</span>  *
<span class='line'> 43</span>  * will cause it to fill the marks "red" on an input value of 1, "green" on an
<span class='line'> 44</span>  * input value of 100, and some color in-between for intermediate values.
<span class='line'> 45</span>  *
<span class='line'> 46</span>  * &lt;p>2. The domain and range can be subdivided for a "poly-log"
<span class='line'> 47</span>  * transformation. For example, you may want a diverging color scale that is
<span class='line'> 48</span>  * increasingly red for small values, and increasingly green for large values:
<span class='line'> 49</span>  *
<span class='line'> 50</span>  * &lt;pre>.fillStyle(pv.Scale.log(1, 10, 100).range("red", "white", "green"))&lt;/pre>
<span class='line'> 51</span>  *
<span class='line'> 52</span>  * The domain can be specified as a series of &lt;i>n&lt;/i> monotonically-increasing
<span class='line'> 53</span>  * values; the range must also be specified as &lt;i>n&lt;/i> values, resulting in
<span class='line'> 54</span>  * &lt;i>n - 1&lt;/i> contiguous log scales.
<span class='line'> 55</span>  *
<span class='line'> 56</span>  * &lt;p>3. Log scales can be inverted for interaction. The {@link #invert} method
<span class='line'> 57</span>  * takes a value in the output range, and returns the corresponding value in the
<span class='line'> 58</span>  * input domain. This is frequently used to convert the mouse location (see
<span class='line'> 59</span>  * {@link pv.Mark#mouse}) to a value in the input domain. Note that inversion is
<span class='line'> 60</span>  * only supported for numeric ranges, and not colors.
<span class='line'> 61</span>  *
<span class='line'> 62</span>  * &lt;p>4. A scale can be queried for reasonable "tick" values. The {@link #ticks}
<span class='line'> 63</span>  * method provides a convenient way to get a series of evenly-spaced rounded
<span class='line'> 64</span>  * values in the input domain. Frequently these are used in conjunction with
<span class='line'> 65</span>  * {@link pv.Rule} to display tick marks or grid lines.
<span class='line'> 66</span>  *
<span class='line'> 67</span>  * &lt;p>5. A scale can be "niced" to extend the domain to suitable rounded
<span class='line'> 68</span>  * numbers. If the minimum and maximum of the domain are messy because they are
<span class='line'> 69</span>  * derived from data, you can use {@link #nice} to round these values down and
<span class='line'> 70</span>  * up to even numbers.
<span class='line'> 71</span>  *
<span class='line'> 72</span>  * @param {number...} domain... domain values.
<span class='line'> 73</span>  * @returns {pv.Scale.log} a log scale.
<span class='line'> 74</span>  */</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="NAME">pv.Scale.log</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">pv.identity</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> 
<span class='line'> 78</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.search</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">    </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.max</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Math.min</span><span class="PUNC">(</span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">log</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">[</span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 85</span> 
<span class='line'> 86</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">log</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pv.logSymmetric</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 90</span> 
<span class='line'> 91</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 92</span>    * Sets or gets the input domain. This method can be invoked several ways:
<span class='line'> 93</span>    *
<span class='line'> 94</span>    * &lt;p>1. &lt;tt>domain(min, ..., max)&lt;/tt>
<span class='line'> 95</span>    *
<span class='line'> 96</span>    * &lt;p>Specifying the domain as a series of numbers is the most explicit and
<span class='line'> 97</span>    * recommended approach. Most commonly, two numbers are specified: the minimum
<span class='line'> 98</span>    * and maximum value. However, for a diverging scale, or other subdivided
<span class='line'> 99</span>    * poly-log scales, multiple values can be specified. Values can be derived
<span class='line'>100</span>    * from data using {@link pv.min} and {@link pv.max}. For example:
<span class='line'>101</span>    *
<span class='line'>102</span>    * &lt;pre>.domain(1, pv.max(array))&lt;/pre>
<span class='line'>103</span>    *
<span class='line'>104</span>    * An alternative method for deriving minimum and maximum values from data
<span class='line'>105</span>    * follows.
<span class='line'>106</span>    *
<span class='line'>107</span>    * &lt;p>2. &lt;tt>domain(array, minf, maxf)&lt;/tt>
<span class='line'>108</span>    *
<span class='line'>109</span>    * &lt;p>When both the minimum and maximum value are derived from data, the
<span class='line'>110</span>    * arguments to the &lt;tt>domain&lt;/tt> method can be specified as the array of
<span class='line'>111</span>    * data, followed by zero, one or two accessor functions. For example, if the
<span class='line'>112</span>    * array of data is just an array of numbers:
<span class='line'>113</span>    *
<span class='line'>114</span>    * &lt;pre>.domain(array)&lt;/pre>
<span class='line'>115</span>    *
<span class='line'>116</span>    * On the other hand, if the array elements are objects representing stock
<span class='line'>117</span>    * values per day, and the domain should consider the stock's daily low and
<span class='line'>118</span>    * daily high:
<span class='line'>119</span>    *
<span class='line'>120</span>    * &lt;pre>.domain(array, function(d) d.low, function(d) d.high)&lt;/pre>
<span class='line'>121</span>    *
<span class='line'>122</span>    * The first method of setting the domain is preferred because it is more
<span class='line'>123</span>    * explicit; setting the domain using this second method should be used only
<span class='line'>124</span>    * if brevity is required.
<span class='line'>125</span>    *
<span class='line'>126</span>    * &lt;p>3. &lt;tt>domain()&lt;/tt>
<span class='line'>127</span>    *
<span class='line'>128</span>    * &lt;p>Invoking the &lt;tt>domain&lt;/tt> method with no arguments returns the
<span class='line'>129</span>    * current domain as an array of numbers.
<span class='line'>130</span>    *
<span class='line'>131</span>    * @function
<span class='line'>132</span>    * @name pv.Scale.log.prototype.domain
<span class='line'>133</span>    * @param {number...} domain... domain values.
<span class='line'>134</span>    * @returns {pv.Scale.log} &lt;tt>this&lt;/tt>, or the current domain.
<span class='line'>135</span>    */</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">  </span><span class="NAME">scale.domain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">min</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">max</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">array</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">min</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.identity</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">max</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">min</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">        </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">pv.min</span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">min</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pv.max</span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">max</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">        </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Array.prototype.slice.call</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">      </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.map</span><span class="PUNC">(</span><span class="NAME">log</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>150</span> 
<span class='line'>151</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>152</span>    * @function
<span class='line'>153</span>    * @name pv.Scale.log.prototype.range
<span class='line'>154</span>    * @param {...} range... range values.
<span class='line'>155</span>    * @returns {pv.Scale.log} &lt;tt>this&lt;/tt>.
<span class='line'>156</span>    */</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">  </span><span class="NAME">scale.range</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">      </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Array.prototype.slice.call</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">      </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">r.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">        </span><span class="NAME">i.push</span><span class="PUNC">(</span><span class="NAME">pv.Scale.interpolator</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">[</span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> 
<span class='line'>169</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>170</span>    * Sets or gets the output range. This method can be invoked several ways:
<span class='line'>171</span>    *
<span class='line'>172</span>    * &lt;p>1. &lt;tt>range(min, ..., max)&lt;/tt>
<span class='line'>173</span>    *
<span class='line'>174</span>    * &lt;p>The range may be specified as a series of numbers or colors. Most
<span class='line'>175</span>    * commonly, two numbers are specified: the minimum and maximum pixel values.
<span class='line'>176</span>    * For a color scale, values may be specified as {@link pv.Color}s or
<span class='line'>177</span>    * equivalent strings. For a diverging scale, or other subdivided poly-log
<span class='line'>178</span>    * scales, multiple values can be specified. For example:
<span class='line'>179</span>    *
<span class='line'>180</span>    * &lt;pre>.range("red", "white", "green")&lt;/pre>
<span class='line'>181</span>    *
<span class='line'>182</span>    * &lt;p>Currently, only numbers and colors are supported as range values. The
<span class='line'>183</span>    * number of range values must exactly match the number of domain values, or
<span class='line'>184</span>    * the behavior of the scale is undefined.
<span class='line'>185</span>    *
<span class='line'>186</span>    * &lt;p>2. &lt;tt>range()&lt;/tt>
<span class='line'>187</span>    *
<span class='line'>188</span>    * &lt;p>Invoking the &lt;tt>range&lt;/tt> method with no arguments returns the current
<span class='line'>189</span>    * range as an array of numbers or colors.
<span class='line'>190</span>    *
<span class='line'>191</span>    * @function
<span class='line'>192</span>    * @name pv.Scale.log.prototype.invert
<span class='line'>193</span>    * @param {...} range... range values.
<span class='line'>194</span>    * @returns {pv.Scale.log} &lt;tt>this&lt;/tt>, or the current range.
<span class='line'>195</span>    */</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">  </span><span class="NAME">scale.invert</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.search</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">    </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.max</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Math.min</span><span class="PUNC">(</span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">[</span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">[</span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">Math.pow</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Math.pow</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> 
<span class='line'>204</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>205</span>    * Returns an array of evenly-spaced, suitably-rounded values in the input
<span class='line'>206</span>    * domain. These values are frequently used in conjunction with {@link
<span class='line'>207</span>    * pv.Rule} to display tick marks or grid lines.
<span class='line'>208</span>    *
<span class='line'>209</span>    * @function
<span class='line'>210</span>    * @name pv.Scale.log.prototype.ticks
<span class='line'>211</span>    * @returns {number[]} an array input domain values to use as ticks.
<span class='line'>212</span>    */</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">  </span><span class="NAME">scale.ticks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">    </span><span class="COMM">// TODO: support multiple domains</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.floor</span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">        </span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.ceil</span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">        </span><span class="NAME">ticks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">start</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">end</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.pow</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">        </span><span class="NAME">ticks.push</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">    </span><span class="NAME">ticks.push</span><span class="PUNC">(</span><span class="NAME">Math.pow</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">end</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ticks</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">ticks.shift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ticks</span><span class="PUNC">[</span><span class="NAME">ticks.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">ticks.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ticks</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>230</span> 
<span class='line'>231</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>232</span>    * Formats the specified tick value using the appropriate precision, assuming
<span class='line'>233</span>    * base 10.
<span class='line'>234</span>    *
<span class='line'>235</span>    * @function
<span class='line'>236</span>    * @name pv.Scale.log.prototype.tickFormat
<span class='line'>237</span>    * @param {number} t a tick value.
<span class='line'>238</span>    * @return {string} a formatted tick value.
<span class='line'>239</span>    */</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">  </span><span class="NAME">scale.tickFormat</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">t.toPrecision</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span> 
<span class='line'>244</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>245</span>    * "Nices" this scale, extending the bounds of the input domain to
<span class='line'>246</span>    * evenly-rounded values. This method uses {@link pv.logFloor} and {@link
<span class='line'>247</span>    * pv.logCeil}. Nicing is useful if the domain is computed dynamically from
<span class='line'>248</span>    * data, and may be irregular. For example, given a domain of
<span class='line'>249</span>    * [0.20147987687960267, 0.996679553296417], a call to &lt;tt>nice()&lt;/tt> might
<span class='line'>250</span>    * extend the domain to [0.1, 1].
<span class='line'>251</span>    *
<span class='line'>252</span>    * &lt;p>This method must be invoked each time after setting the domain (and
<span class='line'>253</span>    * base).
<span class='line'>254</span>    *
<span class='line'>255</span>    * @function
<span class='line'>256</span>    * @name pv.Scale.log.prototype.nice
<span class='line'>257</span>    * @returns {pv.Scale.log} &lt;tt>this&lt;/tt>.
<span class='line'>258</span>    */</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">  </span><span class="NAME">scale.nice</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">    </span><span class="COMM">// TODO: support multiple domains</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">    </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">pv.logFloor</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pv.logCeil</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">    </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.map</span><span class="PUNC">(</span><span class="NAME">log</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>265</span> 
<span class='line'>266</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>267</span>    * Sets or gets the logarithm base. Defaults to 10.
<span class='line'>268</span>    *
<span class='line'>269</span>    * @function
<span class='line'>270</span>    * @name pv.Scale.log.prototype.base
<span class='line'>271</span>    * @param {number} [v] the new base.
<span class='line'>272</span>    * @returns {pv.Scale.log} &lt;tt>this&lt;/tt>, or the current base.
<span class='line'>273</span>    */</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">  </span><span class="NAME">scale.base</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">v</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">      </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">      </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.map</span><span class="PUNC">(</span><span class="NAME">log</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>282</span> 
<span class='line'>283</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>284</span>    * Returns a view of this scale by the specified accessor function &lt;tt>f&lt;/tt>.
<span class='line'>285</span>    * Given a scale &lt;tt>y&lt;/tt>, &lt;tt>y.by(function(d) d.foo)&lt;/tt> is equivalent to
<span class='line'>286</span>    * &lt;tt>function(d) y(d.foo)&lt;/tt>.
<span class='line'>287</span>    *
<span class='line'>288</span>    * &lt;p>This method is provided for convenience, such that scales can be
<span class='line'>289</span>    * succinctly defined inline. For example, given an array of data elements
<span class='line'>290</span>    * that have a &lt;tt>score&lt;/tt> attribute with the domain [0, 1], the height
<span class='line'>291</span>    * property could be specified as:
<span class='line'>292</span>    *
<span class='line'>293</span>    * &lt;pre>.height(pv.Scale.log().range(0, 480).by(function(d) d.score))&lt;/pre>
<span class='line'>294</span>    *
<span class='line'>295</span>    * This is equivalent to:
<span class='line'>296</span>    *
<span class='line'>297</span>    * &lt;pre>.height(function(d) d.score * 480)&lt;/pre>
<span class='line'>298</span>    *
<span class='line'>299</span>    * This method should be used judiciously; it is typically more clear to
<span class='line'>300</span>    * invoke the scale directly, passing in the value to be scaled.
<span class='line'>301</span>    *
<span class='line'>302</span>    * @function
<span class='line'>303</span>    * @name pv.Scale.log.prototype.by
<span class='line'>304</span>    * @param {function} f an accessor function.
<span class='line'>305</span>    * @returns {pv.Scale.log} a view of this scale by the specified accessor
<span class='line'>306</span>    * function.
<span class='line'>307</span>    */</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">  </span><span class="NAME">scale.by</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">by</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">(</span><span class="NAME">f.apply</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">method</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">by</span><span class="PUNC">[</span><span class="NAME">method</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">[</span><span class="NAME">method</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">by</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>313</span> 
<span class='line'>314</span> </span><span class="WHIT">  </span><span class="NAME">scale.domain.apply</span><span class="PUNC">(</span><span class="NAME">scale</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>316</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>317</span> </span></pre></body></html>